<html>
<head>

<style type="text/css" title="currentStyle" media="screen">
	@import "vtes_exp.css";
</style>

<script type="text/javascript">

	function popup(mylink, windowname) {
		if (! window.focus)return true;
		var href;
		if (typeof(mylink) == 'string')
		   href=mylink;
		else
		   href=mylink.href;
		window.open(href, windowname, 'width=240,height=320,scrollbars=no');
			return false;
		}
	
	function go() {
		document.forms[0].submit();
		}
	
</script>

</head>
<body>

<?php

$_GET["card"] = str_replace("{","'",$_GET["card"]);

$expansions = array(2 => "jyh", "vts", "ds", "ah", "sab", "sbw", "fn", "bld", "cam", "an", "bh", "geh", "ten", "kmw", "lob", "nor", "3rd", "soc", "pro", "dem");
$exp_text = array(2 => "Jyhad", "V:TES", "Dark Sovereigns", "Ancient Hearts", "Sabbat", "Sabbat War", "Final Nights", "Bloodlines", "Camarilla Edition", "Anarchs", "Black Hand", "Gehenna", "Tenth Anniversary", "Kindred Most Wanted", "Legacies of Blood", "Nights of Reckoning", "Third Edition", "Sword of Caine", "Promo", "Demo");

$c = 0;
$file = fopen("db_crypt.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
while  (($card = fgetcsv($file, 1000, ",")) !== FALSE) {
    if ($card[0] == $_GET["card"])
        break;
    $c++;
    }
fclose($file);

$file = fopen("db_images.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
for ($i = 0; $i < $c; $i++) {  // skip every card before the one we want
    fgetcsv($file, 1000, ",");
    }
$images = fgetcsv($file, 1000, ",");   // grab the image data for our card
fclose($file);

$file = fopen("db_rarities.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
for ($i = 0; $i < $c; $i++) {  // skip every card before the one we want
    fgetcsv($file, 1000, ",");
    }
$rarities = fgetcsv($file, 1000, ",");   // grab the rarity data for our card
fclose($file);


?>
<div id="inspect">

<div id="inspect_title">
<h1 class="inspect"><?php echo $card[0] ?></h1>
</div>

<!-- <div id="inspect_type"> -->
<?php 
/* 
// echo $card[1];

    $img_tag_open = "<img src=\"icon/icon_type_";
    $img_tag_close = "_32.jpg\" border=\"0\" height=32px width=32px>";
    $img_tag_new_div = "</div><div id=\"inspect_type_2nd\">";

    switch ($card[1]) {
        case "Master":
            echo $img_tag_open."master".$img_tag_close;
            break;
        case "Combat":
            echo $img_tag_open."combat".$img_tag_close;
            break;
        case "Combat / Reaction":
            echo $img_tag_open."combat".$img_tag_close.$img_tag_new_div.$img_tag_open."reaction".$img_tag_close;
            break;
        case "Reaction / Combat":
            echo $img_tag_open."reaction".$img_tag_close.$img_tag_new_div.$img_tag_open."combat".$img_tag_close;
            break;
        case "Action":
            echo $img_tag_open."action".$img_tag_close;
            break;
        case "Action / Combat":
            echo $img_tag_open."action".$img_tag_close.$img_tag_new_div.$img_tag_open."combat".$img_tag_close;
            break;
        case "Action / Reaction":
            echo $img_tag_open."action".$img_tag_close.$img_tag_new_div.$img_tag_open."reaction".$img_tag_close;
            break;
        case "Action Modifier":
            echo $img_tag_open."actionmod".$img_tag_close;
            break;
        case "Action Modifier / Combat":
            echo $img_tag_open."actionmod".$img_tag_close.$img_tag_new_div.$img_tag_open."combat".$img_tag_close;
            break;
        case "Combat / Action Modifier":
            echo $img_tag_open."combat".$img_tag_close.$img_tag_new_div.$img_tag_open."actionmod".$img_tag_close;
            break;
        case "Action Modifier / Reaction":
            echo $img_tag_open."actionmod".$img_tag_close.$img_tag_new_div.$img_tag_open."reaction".$img_tag_close;
            break;
        case "Reaction / Action Modifier":
            echo $img_tag_open."reaction".$img_tag_close.$img_tag_new_div.$img_tag_open."actionmod".$img_tag_close;
            break;
        case "Political Action":
            echo $img_tag_open."action".$img_tag_close.$img_tag_new_div.$img_tag_open."political".$img_tag_close;
            break;
        case "Reaction":
            echo $img_tag_open."reaction".$img_tag_close;
            break;
        case "Equipment":
            echo $img_tag_open."action".$img_tag_close.$img_tag_new_div.$img_tag_open."equipment".$img_tag_close;
            break;
        case "Ally":
            echo $img_tag_open."action".$img_tag_close.$img_tag_new_div.$img_tag_open."ally".$img_tag_close;
            break;
        case "Retainer":
            echo $img_tag_open."action".$img_tag_close.$img_tag_new_div.$img_tag_open."retainer".$img_tag_close;
            break;
        case "Event":
            echo $img_tag_open."event".$img_tag_close;
            break;
        case "Power":
            echo $img_tag_open."power".$img_tag_close;
            break;
        case "Conviction":
            echo $img_tag_open."conviction".$img_tag_close;
            break;
        case "Vampire":
            echo $img_tag_open."master".$img_tag_close;
            break;
        case "Imbued":
            echo $img_tag_open."master".$img_tag_close;
            break;
        default:
            echo "badcardtype\">";
        }
*/
?></div>                                            <!-- type -->

<?php
if ($card[2] !== " ") { ?>
    <div id="inspect_clan">
    <?php
    echo "<img src=\"icon/icon_clan_";
    if (ereg("/",$card[2])) {
        switch ($card[2]) {
            case "Tremere / Tremere antitribu":
                echo "tremere_32.jpg\" border=\"0\" height=32 width=32><br><img src=\"icon/icon_clan_tremere_antitribu";
                break;
            case "Malkavian / Malkavian antitribu":
                echo "malkavian_32.jpg\" border=\"0\" height=32 width=32><br><img src=\"icon/icon_clan_malkavian_antitribu";
                break;
            default:
                echo "ERROR";
                break;
            }
        }
    else
        {
        echo str_replace(" ","_",strtolower($card[2]));
        }
    echo "_32.jpg\" border=\"0\" height=32 width=32>";
?></div>       <!-- clan -->
<?php
    }

if ($card[3] !== " ") { ?>
    <div id="inspect_discipline">
    <?php
    // if ($card[3] == " ") echo "--"; else echo $card[3];
    
    $img_tag_open = "<img src=\"icon/icon_dis_";
    $img_tag_close = "_32.jpg\" border=\"0\" height=32px width=32px>";

    $discipline_data = preg_split("/ ?[\/&] ?/",$card[3]);
    // print_r($discipline_data);
    foreach ($discipline_data as $dis) {
        echo $img_tag_open;
        if ($dis == "Thanatosis")
            echo "thn";
        else if ($dis == "Vision")
            echo "vsn";
        else
            echo strtolower(substr($dis,0,3));
        echo $img_tag_close;
        }
    /*
    switch ($card[3]) {
        case "Animalism":
            echo $img_tag_open."ani".$img_tag_close;
            break;
        case "Auspex":
            echo $img_tag_open."aus".$img_tag_close;
            break;
        case "Celerity":
            echo $img_tag_open."cel".$img_tag_close;
            break;
        case "Chimerstry":
            echo $img_tag_open."chi".$img_tag_close;
            break;
        case "Daimionon":
            echo $img_tag_open."dai".$img_tag_close;
            break;
        case "Dementation":
            echo $img_tag_open."dem".$img_tag_close;
            break;
        case "Dominate":
            echo $img_tag_open."dom".$img_tag_close;
            break;
        case "Fortitude":
            echo $img_tag_open."for".$img_tag_close;
            break;
        case "Melpominee":
            echo $img_tag_open."mel".$img_tag_close;
            break;
        case "Mytherceria":
            echo $img_tag_open."myt".$img_tag_close;
            break;
        case "Necromancy":
            echo $img_tag_open."nec".$img_tag_close;
            break;
        case "Obeah":
            echo $img_tag_open."obe".$img_tag_close;
            break;
        case "Obfuscate":
            echo $img_tag_open."obf".$img_tag_close;
            break;
        case "Obtenebration":
            echo $img_tag_open."obt".$img_tag_close;
            break;
        case "Potence":
            echo $img_tag_open."pot".$img_tag_close;
            break;
        case "Presence":
            echo $img_tag_open."pre".$img_tag_close;
            break;
        case "Protean":
            echo $img_tag_open."pro".$img_tag_close;
            break;
        case "Quietus":
            echo $img_tag_open."qui".$img_tag_close;
            break;
        case "Sanguinus":
            echo $img_tag_open."san".$img_tag_close;
            break;
        case "Serpentis":
            echo $img_tag_open."ser".$img_tag_close;
            break;
        case "Spiritus":
            echo $img_tag_open."spi".$img_tag_close;
            break;
        case "Temporis":
            echo $img_tag_open."tem".$img_tag_close;
            break;
        case "Thaumaturgy":
            echo $img_tag_open."tha".$img_tag_close;
            break;
        case "Thanatosis":
            echo $img_tag_open."thn".$img_tag_close;
            break;
        case "Valeren":
            echo $img_tag_open."val".$img_tag_close;
            break;
        case "Vicissitude":
            echo $img_tag_open."vic".$img_tag_close;
            break;
        case "Visceratika":
            echo $img_tag_open."vis".$img_tag_close;
            break;
        default:
            echo $img_tag_open."BAD_DISCIPLINE".$img_tag_close;
            break;
        }
        */
    ?></div> <!-- discipline -->
<?php } ?>

<div id="inspect_pool"><?php if ($card[3] == " ") echo "--"; else echo $card[3]; ?></div>       <!-- pool --> 
<!-- <div id="inspect_blood"><?php if ($card[8] == " ") echo "--"; else echo $card[8]; ?></div> -->     <!-- blood -->
<!-- <div id="inspect_conviction"><?php if ($card[9] == " ") echo "--"; else echo $card[9]; ?></div> --> <!-- conviction -->
<!-- <div id="inspect_burn"><?php echo $card[10]; ?></div> -->                                          <!-- burn option -->
<!-- <div id="inspect_req"><?php echo $card[11]; ?></div> -->                                            <!-- requirements -->


<div id="inspect_card_text">
<h2 class="inspect">Card Text</h2>
<p class="inspect">
<?php
// echo $card[4];

$card_text = $card[7];
$search_text = array(" / ","(D)",
                     "[ACTION]","[ACTION MODIFIER]","[REACTION]","[COMBAT]",
                     "[1 CONVICTION]","[2 CONVICTION]","[3 CONVICTION]","[4 CONVICTION]","[5 CONVICTION]",
                     "[ani]","[aus]","[cel]","[chi]","[dai]","[dem]","[dom]","[for]","[mel]","[myt]","[nec]","[obe]","[obf]","[obt]","[pot]","[pre]","[pro]","[qui]","[san]","[ser]","[spi]","[tem]","[tha]","[thn]","[val]","[vic]","[vis]",
                     "[ANI]","[AUS]","[CEL]","[CHI]","[DAI]","[DEM]","[DOM]","[FOR]","[MEL]","[MYT]","[NEC]","[OBE]","[OBF]","[OBT]","[POT]","[PRE]","[PRO]","[QUI]","[SAN]","[SER]","[SPI]","[TEM]","[THA]","[THN]","[VAL]","[VIC]","[VIS]");
$replace_text = array("<br>","(D)",
                       "<img src=\"icon/icon_type_action_16.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_type_actionmod_16.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_type_reaction_16.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_type_combat_16.jpg\" border=\"0\" height=24 width=24>",
                       "1 <img src=\"icon/icon_type_conviction_16.jpg\" border=\"0\" height=24 width=24>",
                       "2 <img src=\"icon/icon_type_conviction_16.jpg\" border=\"0\" height=24 width=24>",
                       "3 <img src=\"icon/icon_type_conviction_16.jpg\" border=\"0\" height=24 width=24>",
                       "4 <img src=\"icon/icon_type_conviction_16.jpg\" border=\"0\" height=24 width=24>",
                       "5 <img src=\"icon/icon_type_conviction_16.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_ani_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_aus_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_cel_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_chi_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_dai_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_dem_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_dom_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_for_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_mel_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_myt_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_nec_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_obe_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_obf_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_obt_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_pot_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_pre_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_pro_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_qui_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_san_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_ser_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_spi_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_tem_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_tha_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_thn_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_val_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_vic_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_vis_inf_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_ani_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_aus_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_cel_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_chi_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_dai_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_dem_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_dom_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_for_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_mel_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_myt_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_nec_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_obe_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_obf_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_obt_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_pot_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_pre_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_pro_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_qui_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_san_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_ser_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_spi_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_tem_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_tha_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_thn_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_val_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_vic_sup_24.jpg\" border=\"0\" height=24 width=24>",
                       "<img src=\"icon/icon_dis_vis_sup_24.jpg\" border=\"0\" height=24 width=24>");

echo str_replace($search_text,$replace_text,$card_text);
// echo $card_text;
?></p><?php

if ($card[5] !== " ") {  ?>
<h2 class="inspect">Card Updates</h2>
<p class="inspect"><?php echo $card[8]; ?></p><?php
    }

if ($card[12] !== " ") {  ?>
<h2 class="inspect">Flavor Text</h2>
<span class="flavor_text"><?php echo $card[9]; ?></span>
<?php
    }

if ($card[6] !== " ") {  ?>
<h2 class="inspect">Artist</h2>
<p class="inspect"><?php echo $card[10]; ?></p><?php
    }
?>
</div>

<div id="inspect_printings">
<ul>
<?php
foreach ($rarities as $key => $val) {
    if ($key <= 1)
        continue;
    if ($val == " ")
        continue;
    echo "<li><img src=\"icon/icon_".$expansions[$key]."_th.jpg\" alt=\"".$expansions[$key]."\"> ".$exp_text[$key]." : ";
    
    switch (substr($val,0,1)) {
        case "R":
            echo "Rare";
            break;
        case "U":
        case "V":
            echo "Uncommon";
            break;
        case "C":
            echo "Common";
            break;
        case "A":
            echo "Set A";
            break;
        case "B":
            echo "Set B";
            break;
        case "P":
            echo "Pre-built";
            break;
        case "2":   // Promos have the date in the rarity field.
            echo "Promo";
            break;
        default:
            echo "ERROR";
            break;
        }
    echo "</li>\n";
    } ?>
</ul>
</div>

<!--
<div id="inspect_image">
    <img src="/ebay/<?php echo $images[1]; ?>">
</div>
-->

<?php
/*
foreach ($card as $key => $val) {
    echo "card[$key]=[".$card[$key]."]<br>";
    }

foreach ($images as $key => $val) {
    echo "images[$key]=[".$images[$key]."]<br>";
    }
foreach ($rarities as $key => $val) {
    echo "rarities[$key]=[".$rarities[$key]."]<br>";
    }
?>

<?php
echo '<pre>GET:';
foreach ($_GET as $key => $value) {
	echo '$_GET'."[$key]={$value}\n";
	}
echo '</pre>';
*/
?>

</div>

</body>